<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>layui</title>
  <meta name="renderer" content="webkit">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  <link rel="stylesheet" href="__PUBLIC__/layui/css/layui.css"  media="all">
  <link rel="stylesheet" href="__PUBLIC__/font-awesome/css/font-awesome.min.css" media="all" />
  <link rel="stylesheet" href="__CSS__/admin.css"  media="all">
  <!-- 注意：如果你直接复制所有代码到本地，上述css路径需要改成你本地的 -->
  <style type="text/css">

/* tooltip */
#tooltip{
  position:absolute;
  border:1px solid #ccc;
  background:#333;
  padding:2px;
  display:none;
  color:#fff;
}
.operation-menu a{
  margin: 0;
}
</style>
</head>
<body style="margin: 0 20px">

<fieldset class="layui-elem-field site-demo-button" style="margin-top: 30px;border:0"> 
<form class="layui-form serch" action="{:url('admin/member/member')}" method="post">
    <div class="layui-form-item" style="float: left;margin-bottom: 0px">



      <div class="layui-input-inline">
        <input type="text" name="member_id" lay-verify="title" value="{if isset($wherelist['member_id'])}{$wherelist['member_id']}{/if}" autocomplete="off" placeholder="请输入会员ID" class="layui-input layui-btn-sm">
        <span style="color: red;font-size: 12px">* 如果id如:10200 请输入后4位 </span>
      </div>

      <div class="layui-input-inline">
        <input type="text" name="keywords" lay-verify="title" value="{if isset($wherelist['keywords'])}{$wherelist['keywords']}{/if}" autocomplete="off" placeholder="请输入昵称" class="layui-input layui-btn-sm">
      </div>

      <div class="layui-input-inline">
        <input type="text" name="member_remark" lay-verify="title" value="{if isset($wherelist['member_remark'])}{$wherelist['member_remark']}{/if}" autocomplete="off" placeholder="请输入备注" class="layui-input layui-btn-sm">
      </div>

      <div class="layui-input-inline">
        <input type="text" name="member_phone" lay-verify="title"  value="{if isset($wherelist['member_phone'])}{$wherelist['member_phone']}{/if}" autocomplete="off" placeholder="请输入电话号码" class="layui-input layui-btn-sm">
      </div>

      <div class="layui-input-inline">
        <input type="text" name="member_city" lay-verify="title"  value="{if isset($wherelist['member_city'])}{$wherelist['member_city']}{/if}" autocomplete="off" placeholder="请输入所在城市" class="layui-input layui-btn-sm">
      </div>

      <div class="layui-input-inline">
        <div class="layui-inline">
            <select name="admin_cate_id" lay-search="">
              <option value="">会员等级</option>
              {volist name="$info.cate" id="vo"}
              <option  value="{$vo.member_type_id}" {if isset($wherelist['admin_cate_id']) AND $wherelist['admin_cate_id']==$vo.member_type_id}selected{/if}>{$vo.type_name}</option>
              {/volist}
            </select>
        </div>
      </div>

      <div class="layui-input-inline">
        <div class="layui-inline">
          <select name="is_apply" lay-search="">
            <option value="">会员申请状态</option>
            <option value="10" {if isset($wherelist['is_apply']) AND $wherelist['is_apply']==10 }selected{/if}>未申请</option>
            <option value="11" {if isset($wherelist['is_apply']) AND $wherelist['is_apply']==11 }selected{/if}>已申请</option>
            <option value="12" {if isset($wherelist['is_apply']) AND $wherelist['is_apply']==12 }selected{/if}>已通过</option>

          </select>
        </div>
      </div>
      <div class="layui-input-inline">
        <div class="layui-inline">
          <select name="is_admin" lay-search="">
            <option value="">角色</option>
            <option value="0" {if isset($wherelist['is_admin']) AND $wherelist['is_admin']=='0' }selected{/if}>普通账号</option>
            <option value="1" {if isset($wherelist['is_admin']) AND $wherelist['is_admin']=='1' }selected{/if}>管理员</option>
          </select>
        </div>
      </div>
      <div class="layui-input-inline">
        <div class="layui-inline">
          <div class="layui-input-inline">
            <input type="text" class="layui-input"  value="{if isset($wherelist['create_time'])}{$wherelist['create_time']}{/if}"  id="create_time"  placeholder="创建时间" autocomplete="off" name="create_time">
          </div>
        </div>
      </div>
      <div class="layui-input-inline">
        <div class="layui-inline">
        <button class="layui-btn layui-btn-danger layui-btn-sm" lay-submit="" lay-filter="serch" >提交</button>
        <a href="{:url('member/addmember')}" class="layui-btn layui-btn-sm a_menu">
          添加会员
        </a>
        </div>
      </div>
    </div>
  </form> 
</fieldset>
<table class="layui-table" lay-even="" lay-skin="row" lay-size="sm">
  <colgroup>
    <col width="40">
    <col width="70">
    <col width="50">
    <col width="70">
    <col width="50">
    <col width="50">
    <col width="50">
    <col width="70">
    <col width="70">
    <col width="70">
    <col width="50">
    <col width="40">
    <col width="90">
    <col width="50">
    <col width="100">
  </colgroup>
  <thead>
    <tr>
      <th>ID</th>
      <th>昵称</th>
      <th>头像</th>
      <th>会员等级</th>
      <th>城市</th>
      <th>备注</th>
      <th>手机号</th>
      <th>邮箱</th>
      <th>佣金</th>
      <th>积分</th>
      <th>邀请人昵称</th>
      <th>申请状态</th>
      <th>创建时间</th>
      <th>状态</th>
      <th>操作</th>
    </tr> 
  </thead>
  <tbody>
    {volist name="member" id="vo"}
    <tr>
      <td>{$vo.member_id}</td>
     <td> <a href="{:url('Personal/index',['id'=>$vo.member_id])}" class="a_menu"  style="margin-right: 0;font-size:12px;">{$vo.member_nickname}</a></td> <!--|geturl-->
      <td>{if !empty($vo.thumb.url)}<a href="{$vo.thumb.url}" class="tooltip"><img src="{$vo.thumb.url}" width="20" height="20"></a>{/if}</td>
      <td>{$vo.member_type.type_name}</td>
      <td>{$vo.member_city}</td>
      <td>{$vo.member_remark}</td>
      <td>{$vo.member_phone}</td>
      <td>{$vo.member_email}</td>
      <td>{$vo.member_money}</td>
      <td>{$vo.member_integral}</td>
      <td>{$vo.invitmember}</td>

      <td>
        {switch name="vo.is_apply" }
        {case value="0"} <span style="color: #777">未申请</span>{/case}
        {case value="1"}<span style="color: #FFB800">申请中</span>{/case}
        {case value="2"}<span style="color: green">已通过</span>{/case}
        {default /}
        {/switch}
      </td>

      <td>{$vo.creattime|date="Y-m-d H:i:s",###}</td>

      <td>{if condition='$vo.member_status eq 1'}使用中{else}已禁用{/if}</td>
      <td class="operation-menu">
        <a href="{:url('Personal/index',['id'=>$vo.member_id])}" class="layui-btn layui-btn-xs a_menu"  style="margin:0 0 4px 0;font-size:12px;background: red">详情</a>
        <a href="{:url('member/addmember',['id'=>$vo.member_id])}" class="layui-btn layui-btn-xs a_menu"  style="margin:0 0 4px 0;font-size:12px;">修改</a>
        <a href="{:url('member/extract',['id'=>$vo.member_id])}" class="layui-btn layui-btn-xs a_menu"  style="margin:0 0 4px 0;font-size:12px;">提现</a>
        <a data-id="{$vo.member_id}" class="layui-btn layui-btn-xs layui-btn-normal fakeSendCode"  style="margin:0 0 4px 0;font-size:12px;">验证码</a>
        {if isset($vo['is_admin'])&&$vo['is_admin']==1}
        <a data-id="{$vo.member_id}" class="layui-btn layui-btn-xs layui-btn-danger cancelAdmin"  style="margin:0 0 4px 0;font-size:12px;">取消管理员</a>
        {else}
        <a data-id="{$vo.member_id}" class="layui-btn layui-btn-xs layui-bg-cyan setAdmin"  style="margin:0 0 4px 0;font-size:12px;">设为管理员</a>
        {/if}
        {if condition='$vo.member_status eq 1'}
        <!--<a class="layui-btn layui-btn-xs layui-btn-danger delete" data-id="{//$vo.member_id}" style="margin-right: 0;font-size:12px;">禁用</a>-->
        {else}
        <!--<a class="layui-btn layui-btn-xs layui-btn-danger start" data-id="{//$vo.member_id}" style="margin-right: 0;font-size:12px;">启用</a>-->
        {/if}
      </td>
    </tr>
    {/volist}
  </tbody>
</table>
<div style="padding:0 20px;">{$member->render()}</div>
        
<script src="__PUBLIC__/layui/layui.js" charset="utf-8"></script>
<script src="__PUBLIC__/jquery/jquery.min.js"></script>
<script>
        var message;
        layui.config({
            base: '__JS__/',
            version: '1.0.1'
        }).use(['app', 'message'], function() {
            var app = layui.app,
                $ = layui.jquery,
                layer = layui.layer;
            //将message设置为全局以便子页面调用
            message = layui.message;
            //主入口
            app.set({
                type: 'iframe'
            }).init();
        });
    </script> 
<script type="text/javascript">
$(function(){
  var x = 10;
  var y = 20;
  $(".tooltip").mouseover(function(e){ 
    var tooltip = "<div id='tooltip'><img src='"+ this.href +"' alt='头像' height='200'/>"+"<\/div>"; //创建 div 元素
    $("body").append(tooltip);  //把它追加到文档中             
    $("#tooltip")
      .css({
        "top": (e.pageY+y) + "px",
        "left":  (e.pageX+x)  + "px"
      }).show("fast");    //设置x坐标和y坐标，并且显示
    }).mouseout(function(){  
    $("#tooltip").remove();  //移除 
    }).mousemove(function(e){
    $("#tooltip")
      .css({
        "top": (e.pageY+y) + "px",
        "left":  (e.pageX+x)  + "px"
      });
  });
})

$('.delete').click(function(){
  var id = $(this).attr('data-id');
  layer.confirm('确定要禁用吗?', function(index) {
    $.ajax({
      url:"{:url('admin/member/delete')}",
      data:{
          id:id,
          status:2
      },
      success:function(res) {
        layer.msg(res.msg);
        if(res.code == 1) {
          setTimeout(function(){
            location.href = res.url;
          },1500)
        }
      }
    })
  })
})


$('.start').click(function(){
    var id = $(this).attr('data-id');
    layer.confirm('确定要启用吗?', function(index) {
        $.ajax({
            url:"{:url('admin/member/delete')}",
            data:{
                id:id,
                status:1
            },
            success:function(res) {
                layer.msg(res.msg);
                if(res.code == 1) {
                    setTimeout(function(){
                        location.href = res.url;
                    },1500)
                }
            }
        })
    })
})


</script>
<script type="text/javascript">
layui.use('layer', function(){
  var layer = layui.layer;
  $('.a_menu').click(function(){
    var url = $(this).attr('href');
    var a = 0;
    $.ajax({
      url:url
      ,async:false
      ,success:function(res){
        if(res.code == 0) {
          layer.msg(res.msg);
          a = 1;
        }
      }
    })
    if(a === 0) {
      layer.open({
        type:2,
        content:[url, 'no'],
        area: ['700px', '600px'],
        end:function(){
          location.reload();
        }
      });
    }
    return false;
  })
  $(".fakeSendCode").click(function(){
        var member_id = $(this).attr('data-id');
        layer.confirm('确定获取用户验证码?', function(index) {
            $.post("{:url('admin/member/fakeSendCode')}",{member_id:member_id},function(res){
                if(res.code>0){
                    layer.msg(res.msg,{time:2000});
                }else{
                    layer.msg(res.msg);
                }
            },'json')
        })
    })
    $(".setAdmin").click(function(){
        var member_id = $(this).attr('data-id');
        layer.confirm('确定设置用户账号为管理员吗?', function(index) {
            $.post("{:url('admin/member/updateMemberAdmin')}",{member_id:member_id,admin:1},function(res){
                layer.msg(res.msg);
                if(res.code>0){
                    setTimeout(function(){
                        window.location.reload();
                    },1000)
                }
            },'json')
        })
    })
    $(".cancelAdmin").click(function(){
        var member_id = $(this).attr('data-id');
        layer.confirm('确定设置用户账号为普通账号吗?', function(index) {
            $.post("{:url('admin/member/updateMemberAdmin')}",{member_id:member_id,admin:0},function(res){
                layer.msg(res.msg);
                if(res.code>0){
                    setTimeout(function(){
                        window.location.reload();
                    },1000)
                }
            },'json')
        })
    })
});
</script>
<script>
layui.use('laydate', function(){
  var laydate = layui.laydate;
  
  //常规用法
  laydate.render({
    elem: '#create_time'
  });
});
</script>
</body>
</html>
